package com.example.dbmysql.service.impl;


import com.example.dbmysql.mapper.RoomListMapper;
import com.example.dbmysql.pojo.RoomList;
import com.example.dbmysql.service.RoomListService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


@Service
public class roomListServiceImpl implements RoomListService {

    @Autowired
    private RoomListMapper roomListMapper;
    @Override
    public void batchAdd(Object roomList) {
        roomListMapper.batchAdd(roomList);
    }

    @Override
    public List<RoomList> GetRoomList() {

        return roomListMapper.GetRoomList();
    }

    @Override
    public PageInfo<RoomList> SelectAll(int page, int pageSize) {
        PageHelper.startPage(page, pageSize);
        // 查询全部数据
        List<RoomList> AllRoomList = roomListMapper.SelectAll(page, pageSize);

        PageInfo<RoomList> pageInfo = new PageInfo<>(AllRoomList);

        return pageInfo;
    }

    @Override
    public List<RoomList> selectById(Integer id) {

        return   roomListMapper.selectById(id);
    }

    @Override
    public void update(RoomList roomList) {
        roomList.setUpdateTimer(LocalDateTime.now());
        roomListMapper.update(roomList);
    }

    @Override
    public void delectById(Integer id) {
        roomListMapper.delectById(id);
    }

    @Override
    public void deleteByIds(List id) {
        roomListMapper.deleteByIds(id);
    }

    @Override
    public void updateStatusByRoomName(String roomName,int status) {
        roomListMapper.updateStatusByRoomName(roomName,status);
    }

    @Override
    public RoomList selectByRoomName(String roomName) {
       return roomListMapper.selectByRoomName(roomName);
    }
}
